﻿@using Volo.Abp.UI.Navigation

@{
    var elementId = MenuItem.ElementId ?? "MenuItem_" + MenuItem.Name.Replace(".", "_");
    var cssClass = string.IsNullOrEmpty(MenuItem.CssClass) ? string.Empty : MenuItem.CssClass;
    var disabled = MenuItem.IsDisabled ? "disabled" : string.Empty;
    var url = MenuItem.Url == null ? "#" : MenuItem.Url.TrimStart('/', '~');
}

@if (MenuItem.IsLeaf)
{
    if (MenuItem.Url is not null)
    {
        <MudNavLink Icon="@MenuItem.Icon" Href="@url" Target="@MenuItem.Target">
            @MenuItem.DisplayName
        </MudNavLink>
    }
}
else
{
    <MudNavGroup Icon="@MenuItem.Icon" Title="@MenuItem.DisplayName">
        @foreach (var childMenuItem in MenuItem.Items.OrderBy(i => i.Order))
        {
            <SecondLevelNavMenuItem MenuItem="@childMenuItem"/>
        }
    </MudNavGroup>
}